package com.lianzhihui.minitiktok.ui.main.four

import android.app.DatePickerDialog
import android.view.View
import android.widget.DatePicker
import com.echofeng.common.inter.CustomCallback
import com.echofeng.common.ui.base.BaseActivity
import com.lianzhihui.minitiktok.widget.dialog.ChooseSexDialog
import com.lianzhihui.onlyleague.R
import kotlinx.android.synthetic.main.activity_edit_info.*
import java.lang.String
import java.util.*


class EditInfoActivity : BaseActivity(),View.OnClickListener,DatePickerDialog.OnDateSetListener {
    override fun getLayoutId(): Int {
        return R.layout.activity_edit_info
    }

    override fun initView() {
        setTitle("编辑资料")
        setOption("保存",this);
        item_setting1.setOnClickListener(this)
        item_setting3.setOnClickListener(this)
        item_setting4.setOnClickListener(this)
        item_setting5.setOnClickListener(this)
    }

    override fun onDateSet(p0: DatePicker?, p1: Int, p2: Int, p3: Int) {
        val desc = String.format("%d年%d月%d日", p1,p3 + 1, p3)
        tv_birthday.setText(desc)
    }
    override fun onClick(v: View?) {
        if (v != null) {
            when(v.id){
                R.id.item_setting1->{}
                R.id.item_setting3->{
                    ChooseSexDialog(this, object : CustomCallback {
                        override fun onCompare(o: Any) {}
                        override fun onCancel() {}
                    }).show()
                }
                R.id.item_setting4->{
                    val calendar: Calendar = Calendar.getInstance()
                    //构建一个日期对话框，该对话框已经集成了日期选择器
                    //DatePickerDialog的第二个构造参数指定了日期监听器
                    //构建一个日期对话框，该对话框已经集成了日期选择器
                    //DatePickerDialog的第二个构造参数指定了日期监听器
                    val dialog = DatePickerDialog(this, this,
                            calendar.get(Calendar.YEAR),
                            calendar.get(Calendar.MONTH ),
                            calendar.get(Calendar.DAY_OF_MONTH))
                    //把日期对话框显示在界面上
                    //把日期对话框显示在界面上
                    dialog.show()
                }
                R.id.item_setting5->{}
            }
        }
    }

}